package cc.aiee.wxpay.core.tool;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;

public class WxPayScoreTool {

	public static Map<String, Object> toMinAppCreateDto(JSONObject jso, String minappSecret) {
		Map<String, Object> map = new HashMap<>();
		map.put("mch_id", jso.getString("mchid"));
		map.put("package", jso.getString("package"));
		map.put("timestamp", String.valueOf(DateUtil.currentSeconds()));
		map.put("nonce_str", RandomUtil.randomString(16));
		map.put("sign_type", "HMAC-SHA256");
		WxPayTool.signHmacSHA256(map, minappSecret);
		return map;
	}

	public static String returnNotifyMsg() {
		JSONObject jsb = new JSONObject();
		jsb.put("code", "SUCCESS");
		jsb.put("message", null);
		return jsb.toJSONString();
	}
}
